package cn.software.util;

public class Result {

    int code;
    String msg;
    Object data;

    public Result() {
    }

    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static Result success(Object data) {
        return new Result(200, "成功", data);
    }

    public static Result fail(String msg) {
        return new Result(ResultEnum.FAIL_DEFAULT.code, msg, null);
    }

    public static Result testAddFail(Object data){
        return new Result(ResultEnum.FAIL_TIME.code,ResultEnum.FAIL_TIME.msg,data);
    }


    public static Result fail(ResultEnum resultEnum) {
        return new Result(resultEnum.code, resultEnum.msg, null);
    }
}
